from datetime import datetime
from pydantic import BaseModel, ConfigDict, Field
from pydantic.alias_generators import to_camel
from pydantic_validation_decorator import NotBlank
from typing import Optional
from module_admin.annotation.pydantic_annotation import as_query




class Kh_monthly_attendanceModel(BaseModel):
    """
    考勤月报表表对应pydantic模型
    """
    model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)

    id: Optional[int] = Field(default=None, description='序号')
    user_name: Optional[str] = Field(default=None, description='用户姓名')
    user_id: Optional[str] = Field(default=None, description='用户编号')
    kh_month: Optional[str] = Field(default=None, description='考勤月份')
    am_pm: Optional[str] = Field(default=None, description='考勤时段')
    kh_work: Optional[str] = Field(default=None, description='考勤类型')
    day1: Optional[str] = Field(default=None, description='1日')
    day2: Optional[str] = Field(default=None, description='2日')
    day3: Optional[str] = Field(default=None, description='3日')
    day4: Optional[str] = Field(default=None, description='4日')
    day5: Optional[str] = Field(default=None, description='5日')
    day6: Optional[str] = Field(default=None, description='6日')
    day7: Optional[str] = Field(default=None, description='7日')
    day8: Optional[str] = Field(default=None, description='8日')
    day9: Optional[str] = Field(default=None, description='9日')
    day10: Optional[str] = Field(default=None, description='10日')
    day11: Optional[str] = Field(default=None, description='11日')
    day12: Optional[str] = Field(default=None, description='12日')
    day13: Optional[str] = Field(default=None, description='13日')
    day14: Optional[str] = Field(default=None, description='14日')
    day15: Optional[str] = Field(default=None, description='15日')
    day16: Optional[str] = Field(default=None, description='16日')
    day17: Optional[str] = Field(default=None, description='17日')
    day18: Optional[str] = Field(default=None, description='18日')
    day19: Optional[str] = Field(default=None, description='19日')
    day20: Optional[str] = Field(default=None, description='20日')
    day21: Optional[str] = Field(default=None, description='21日')
    day22: Optional[str] = Field(default=None, description='22日')
    day23: Optional[str] = Field(default=None, description='23日')
    day24: Optional[str] = Field(default=None, description='24日')
    day25: Optional[str] = Field(default=None, description='25日')
    day26: Optional[str] = Field(default=None, description='26日')
    day27: Optional[str] = Field(default=None, description='27日')
    day28: Optional[str] = Field(default=None, description='28日')
    day29: Optional[str] = Field(default=None, description='29日')
    day30: Optional[str] = Field(default=None, description='30日')
    day31: Optional[str] = Field(default=None, description='31日')
    del_flag: Optional[str] = Field(default=None, description='删除标志')
    create_by: Optional[str] = Field(default=None, description='创建者')
    create_time: Optional[datetime] = Field(default=None, description='创建时间')
    update_by: Optional[str] = Field(default=None, description='更新者')
    update_time: Optional[datetime] = Field(default=None, description='更新时间')
    remark: Optional[str] = Field(default=None, description='备注')

    @NotBlank(field_name='user_name', message='用户姓名不能为空')
    def get_user_name(self):
        return self.user_name

    @NotBlank(field_name='user_id', message='用户编号不能为空')
    def get_user_id(self):
        return self.user_id

    @NotBlank(field_name='kh_month', message='考勤月份不能为空')
    def get_kh_month(self):
        return self.kh_month

    @NotBlank(field_name='am_pm', message='考勤时段不能为空')
    def get_am_pm(self):
        return self.am_pm

    @NotBlank(field_name='kh_work', message='考勤类型不能为空')
    def get_kh_work(self):
        return self.kh_work


    def validate_fields(self):
        self.get_user_name()
        self.get_user_id()
        self.get_kh_month()
        self.get_am_pm()
        self.get_kh_work()




class Kh_monthly_attendanceQueryModel(Kh_monthly_attendanceModel):
    """
    考勤月报表不分页查询模型
    """

    begin_time: Optional[str] = Field(default=None, description='开始时间')
    end_time: Optional[str] = Field(default=None, description='结束时间')


@as_query
class Kh_monthly_attendancePageQueryModel(Kh_monthly_attendanceQueryModel):
    """
    考勤月报表分页查询模型
    """

    page_num: int = Field(default=1, description='当前页码')
    page_size: int = Field(default=10, description='每页记录数')


class DeleteKh_monthly_attendanceModel(BaseModel):
    """
    删除考勤月报表模型
    """

    model_config = ConfigDict(alias_generator=to_camel)

    ids: str = Field(description='需要删除的序号')
